package us.wili.dev.common.util.sms;

/**
 * Created by JasonY on 17/6/5.
 */
public enum AliyunErrorCodeEnum {
    DEFAULT_EXCEPTION("isv.API_EXCEPTION","系统繁忙，请稍后再试"),

    OUT_OF_SERVICE("isv.OUT_OF_SERVICE", "101:短信验证码下发失败"),
    PRODUCT_UNSUBSCRIBE("isv.PRODUCT_UNSUBSCRIBE", "102:短信验证码下发失败"),
    ACCOUNT_NOT_EXISTS("isv.ACCOUNT_NOT_EXISTS", "短信网关服务不存在"),
    ACCOUNT_ABNORMAL("isv.ACCOUNT_ABNORMAL", "短信网关账户信息异常"),
    SMS_TEMPLATE_ILLEGAL("isv.SMS_TEMPLATE_ILLEGAL", "模板不合法"),
    SMS_SIGNATURE_ILLEGAL("isv.SMS_SIGNATURE_ILLEGAL", "签名不合法"),
    MOBILE_NUMBER_ILLEGAL("isv.MOBILE_NUMBER_ILLEGAL", "手机号码格式错误"),
    MOBILE_COUNT_OVER_LIMIT("isv.MOBILE_COUNT_OVER_LIMIT", "手机号码数量超过限制"),
    TEMPLATE_MISSING_PARAMETERS("isv.TEMPLATE_MISSING_PARAMETERS", "短信模板变量缺少参数"),
    INVALID_PARAMETERS("isv.INVALID_PARAMETERS", "参数异常"),
    BUSINESS_LIMIT_CONTROL("isv.BUSINESS_LIMIT_CONTROL", "请求过于频繁，请稍后重试"),
    INVALID_JSON_PARAM("isv.INVALID_JSON_PARAM", "JSON参数不合法"),
    SYSTEM_ERROR("isv.SYSTEM_ERROR", "短信网关异常"),
    BLACK_KEY_CONTROL_LIMIT("isv.BLACK_KEY_CONTROL_LIMIT", "模板变量中存在黑名单关键字"),
    PARAM_NOT_SUPPORT_URL("isv.PARAM_NOT_SUPPORT_URL", "不支持url为变量"),
    PARAM_LENGTH_LIMIT("isv.PARAM_LENGTH_LIMIT", "变量长度受限"),
    AMOUNT_NOT_ENOUGH("isv.AMOUNT_NOT_ENOUGH", "103:短信验证码下发失败"),
    RAM_PERMISSION_DENY("isp.RAM_PERMISSION_DENY","帐号异常"),
    PRODUCT_UN_SUBSCRIPT("isv.PRODUCT_UN_SUBSCRIPT","帐号异常")

    ;

    private String subCode;
    private String msg;

    private AliyunErrorCodeEnum(String subCode, String msg) {
        this.subCode = subCode;
        this.msg = msg;
    }

    public String getSubCode() {
        return subCode;
    }

    public void setSubCode(String subCode) {
        this.subCode = subCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static AliyunErrorCodeEnum get(String subCode) {
        if (subCode == null) {
            return null;
        }

        for (AliyunErrorCodeEnum codeEnum : AliyunErrorCodeEnum.values()) {
            if (codeEnum.getSubCode().equals(subCode)) {
                return codeEnum;
            }
        }

        return null;
    }
}
